home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / schmlbrr / schem_lb.lha / unsupported / CScheme / macro-hacks.scm < prev    next >
Encoding:
Text File  |  1991-08-05  |  1.5 KB  |  49 lines

  1. ;;; -*- Base: 10; Mode: Scheme; Syntax: MIT Scheme; Package: USER-*-
  2. ;;
  3. ;; MARCO-HACKS.SCM
  4. ;;
  5. ;; June 29, 1991
  6. ;; Minghsun Liu
  7. ;;
  8. ;; This file contains some definitions taken from the file `Macros in
  9. ;; MIT Scheme' that makes the macros in MIT Scheme behave more like
  10. ;; that in CommonLisp.
  11. ;;
  12. ;; P.S. Since I am still not sure if the macros in Scheme support
  13. ;; destructuring, I am using the variable name CRUDE-INPUT in any
  14. ;; macros that used destructuring in the original CommonLisp to
  15. ;; represent those arguments.  The destructuring is then done by the
  16. ;; program itself.  - lmh
  17. ;;
  18. ;;
  19. ;; The following(s) are(is) defined:
  20. ;;
  21. ;; (DEFMACRO PATTERN . BODY)
  22. ;; 
  23. (declare (usual-integrations))
  24.  
  25. ;;
  26. ;; (DEFMACRO PATTERN . BODY)
  27. ;;
  28. ;; is a MIT Scheme macro that allows a macro defined in a file to be
  29. ;; available for use both in a given file and the REP loop.
  30. ;;
  31. (define-macro (defmacro pattern . body)
  32.   `(begin
  33.      (define-macro ,pattern ,@body)
  34.      (syntax-table-define user-initial-syntax-table ',(car pattern)
  35.                           (macro ,(cdr pattern) ,@body))))
  36.  
  37. ;;
  38. ;; What follows allows a macro to be available in a given file, in the
  39. ;; REP loop, and in source files loaded into (or compiled by) the
  40. ;; Scheme system.
  41. ;;
  42. (syntax-table-define system-global-syntax-table 'defmacro
  43.   (macro (pattern . body)
  44.     `(begin
  45.        (define-macro ,pattern ,@body)
  46.        (syntax-table-define system-global-syntax-table ',(car pattern)
  47.          (macro ,(cdr pattern)
  48.            ,@body)))))
  49.